<template>

	<view class="authenticate">

		<view class="header">

			<text class="h_title">{{ dataInfo.diseaseName || '---' }}</text>

			<text>发布者：{{ this.$replaceLastStr(dataInfo.ownerUserName) || this.$replaceLastStr(this.$storage.getItem('roleDataInfo').name) }}</text>

		</view>

		<view class="main">

			<view class="m_list">

				<text class="m_title">【患者基本信息】：</text>

				<view class="m_message">

					<text class="handLetterSpa">姓名：{{ dataInfo.name || '---' }}</text>

					<text
						class="handLetterSpa">性别：{{ dataInfo.gender == 0 ? '保密': dataInfo.gender == 1? '男' : '女' }}</text>

					<text class="handLetterSpa">地址：{{ dataInfo.address || '---' }}</text>

				</view>

			</view>

			<view class="m_list">

				<view class="m_module">

					<text class="m_title">【详细情况(患病过程、治疗经历、目前状况)】：</text>

					<view class="m_con handLetterSpa">

						<text>{{ dataInfo.details || '---' }}</text>

					</view>

					<view class="m_module" v-if="dataInfo.fileList">

						<text class="m_title">【附件(相关照片、检查、医院诊断书)】：</text>

						<view class="m_con handLetterSpa">

							<view class="fileImage">

								<image @click="getBigImg(el)" v-for="(el, index) in dataInfo.fileList" :key="index"
									:src="el"></image>

							</view>

						</view>

					</view>

				</view>

				<view class="m_list offPadding" v-if="status == 1">

					<view class="m_module">

						<text class="m_title">{{ valType==1?'【鉴定情况】': '【回复】' }}：</text>

						<view class="m_con handLetterSpa">

							<van-field :value="dataValue.replyContent" type="textarea"
								:placeholder="valType==1 ? '请输入鉴定情况': '请输入回复'" :autosize="{ minHeight: 40 }"
								@input="textValue" />

						</view>

					</view>

					<view class="btnBox">

						<van-button type="default" @click="confim('success')">完成</van-button>

						<van-button color="#98A0A6" @click="confim('cancel')">取消</van-button>

					</view>

				</view>

			</view>

			<showImg :show="comInfo.showBigImg" :src="comInfo.src" @close="close" />

			<van-toast id='van-toast' />

		</view>

	</view>

</template>



<script>
	import {
		seekHelpGetById,
		seekHelpReply
	} from '@/api/my'

	import {
		fileById
	} from '@/api/common'

	import showImg from '@/components/showBigImg'

	export default {

		name: 'authenticate',

		components: {
			showImg
		},

		data() {

			return {

				status: 1,

				valType: '2',

				dataValue: {

					replyContent: '',

					helpId: ''

				},

				dataInfo: {},

				comInfo: {

					showBigImg: false,

					src: ''

				}

			}

		},

		onLoad(option) {

			this.getDataInfo(option.id, option.name);

			this.status = option.status;

		},

		methods: {

			getDataInfo(id, name) {

				seekHelpGetById({
					id: id
				}).then(res => {

					this.dataInfo = res.data;

					this.dataInfo.diseaseName = name;

					this.dataValue.helpId = res.data.id;

					this.getFile(res.data.fileIdList, 'fileList');

				})

			},

			getFile(val, typeName) {

				let arr = [];

				val.map(item => {

					fileById({
						fileId: item
					}).then(res => {

						arr.push(res.data.accessUrl)

					})

				})

				this.$set(this.dataInfo, typeName, arr);

			},

			textValue(e) {

				let value = e.detail;

				this.dataValue.replyContent = value;

				if (this.valType == 1) {



				} else {



				}

			},

			// 评分

			onChange(e) {

				this.dataValue.starLevel = e.detail;

				this.dataValue.starLVal = Number(e.detail) * 2;

			},

			confim(mode) {

				if (mode == 'success') {

					if (!this.dataValue.replyContent) {

						return this.$toast.fail('请输入回复')

					}

					seekHelpReply(this.dataValue).then(res => {

						uni.showToast({

							title: '回复成功',

							duration: 2000,

							icon: 'success'

						});

						setTimeout(() => {

							uni.navigateBack();

						}, 1000)

					})

				} else {

					uni.navigateBack({

						delta: 1

					});

				}

			},

			getBigImg(el) {

				this.comInfo.showBigImg = true;

				this.comInfo.src = el;

			},

			close(val) {

				this.comInfo.showBigImg = val;

			}

		}

	}
</script>



<style lang="scss" scoped>
	.authenticate {

		width: 100%;

		position: relative;

		padding: 0 20rpx 60rpx;

		box-sizing: border-box;

		.header {

			padding: 0 15% 40rpx;

			text {

				display: block;

				width: 100%;

				text-align: right;

				font-size: 28rpx;

			}

			.h_title {

				padding-bottom: 20rpx;

				font-size: 40rpx;

				text-align: center;

				font-weight: 600;

			}

		}

		.main {

			width: 100%;

			/deep/ .van-cell {

				border: 1rpx solid #0f0f0f;

				word-break: break-all;

				word-wrap: break-word;

				text-align: justify;

			}

			.btnBox {

				width: 100%;

				box-sizing: border-box;

				padding: 30rpx 90rpx 0;

				display: flex;

				align-items: center;

				justify-content: space-between;

				/deep/ .van-button {

					width: 200rpx;

					height: 80rpx;

					line-height: 80rpx;

					border-radius: 10rpx;

				}

			}

			.offPadding {

				padding-right: 0;

				padding-left: 0;

				border: none;

			}

		}

	}
</style>
